home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / lib / calc / bigprime.cal < prev    next >
Text File  |  1995-07-17  |  555b  |  33 lines

  1. /*
  2.  * Copyright (c) 1993 David I. Bell
  3.  * Permission is granted to use, distribute, or modify this source,
  4.  * provided that this copyright notice remains intact.
  5.  *
  6.  * A prime test, base a, on p*2^x+1 for even x>m.
  7.  */
  8.  
  9. define bigprime(a, m, p)
  10. {
  11.     local n1, n;
  12.  
  13.     n1 = 2^m * p;
  14.     for (;;) {
  15.         m++;
  16.         n1 += n1;
  17.         n = n1 + 1;
  18.         if (isodd(m))
  19.             continue;
  20.         print m;
  21.         if (pmod(a, n1 / 2, n) != n1)
  22.             continue;
  23.         if (pmod(a, n1 / p, n) == 1)
  24.             continue;
  25.         print "    " : n;
  26.     }
  27. }
  28.  
  29. global lib_debug;
  30. if (lib_debug >= 0) {
  31.     print "bigprime(a, m, p) defined";
  32. }
  33.